package edu.lfsfxy.myschool.dao;

import edu.lfsfxy.myschool.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository//表明该类是Dao
public interface StudentDao {
    @Select("SELECT * FROM `student`")
    List<Student> findAll();
    @Select("SELECT * FROM `student` where sno=#{sno}")
    Student findBySno(int sno);
    @Delete("DELETE FROM `student` WHERE `sno`=#{sno}")
    int delete(int sno);
    @Insert("INSERT INTO `student` VALUES(#{sno},#{sname},#{sex},#{phone},#{address},#{birthday},#{email})")
    int add(Student stu);
    @Update("UPDATE `student` set sname=#{sname},sex=#{sex},phone=#{phone},address=#{address},birthday=" +
            "#{birthday},email=#{email} WHERE `sno`=#{sno}")
    int update(Student stu);
}
